home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 12 / CU Amiga Magazine's Super CD-ROM 12 (1997)(EMAP Images)(GB)[!][issue 1997-07].iso / CUCD / Games / DestructivePoker / sources / sources.lha / betprefs.cpp next >
C/C++ Source or Header  |  1997-02-13  |  4KB  |  175 lines

  1. /*
  2.         betprefs.cpp
  3.  
  4.         V1.00 - 241196  Kimmo Teräväinen
  5.         -----   ------  ----------------
  6.         Look betprefs.h
  7.  
  8. */
  9.  
  10. #include "betprefs.h"
  11.  
  12. #ifdef _Windows
  13.  
  14. DEFINE_RESPONSE_TABLE1(TPrefsBetDialog,TDialog)
  15. //  EV_CBN_SelChange(COMBO_CHANGES,Sel_Changes);
  16. //  EV_CBN_SelChange(COMBO_JOKERS ,Sel_Jokers);
  17.   EV_BN_CLICKED(IDOK            ,ButtonOK),
  18. END_RESPONSE_TABLE;
  19.  
  20. const char *TPrefsBetDialog::Numerot[] = {
  21.   "0",
  22.   "1",
  23.   "2",
  24.   "3",
  25.   "4",
  26.   "5",
  27.   "6",
  28.   "7",
  29.   "8"
  30. };
  31.  
  32. void TPrefsBetDialog::SetupWindow()
  33. {
  34.   int i;
  35.   TDialog::SetupWindow();
  36.   for(i=1; i<=MAX_CHANGES ; i++)
  37.     changes.InsertString(Numerot[i],i-1);
  38.  
  39.   for(i=0; i<=MAX_JOKERS ; i++)
  40.     jokers.InsertString(Numerot[i],i);
  41.  
  42.   changes.SetSelIndex(game->Changes()-1);
  43.   jokers.SetSelIndex(game->Jokers());
  44. }
  45.  
  46. #else
  47. #include <inline++/exec.h>
  48.  
  49. #include "pokergadgets.h"
  50.  
  51.  
  52. const cButton cPrefsBetGadgets::PrefsBetButtons[] = {
  53.   cButton(GADGET_OK    ,30,100,52,20,"OK"),
  54.   cButton(GADGET_CANCEL,300,100,52,20,"Cancel"),
  55.   cButton(0,0,0,0,0,NULL)
  56. };
  57.  
  58. const cStringGadget cPrefsBetGadgets::PrefsBetStringGads[] = {
  59.   cStringGadget(STRING_CHANGES,130,30,30,12,"_Changes:","1",1),
  60.   cStringGadget(STRING_JOKERS ,130,50,30,12,"_Jokers:","2",1),
  61. //  cStringGadget(0,0,0,0,0,NULL,NULL,0)
  62. };
  63.  
  64.  
  65. void TPrefsBetDialog::Execute()
  66. {
  67.   Window *Wnd=NULL;
  68.   int BTop = parent->WScreen->WBorTop + (parent->WScreen->Font->ta_YSize + 1);
  69.  
  70.   {
  71.     struct TagItem window_tags[] = {
  72.       { WA_Title, (long unsigned)"Game Preferences" },
  73.       { WA_DragBar , TRUE},
  74.       { WA_DepthGadget , TRUE},
  75.       { WA_CloseGadget, TRUE },
  76.       { WA_Left, 100+parent->LeftEdge }, { WA_Top, 50+parent->TopEdge },
  77.       { WA_Width, 390 }, { WA_Height, 130+BTop },
  78.       { WA_CustomScreen, (ULONG)parent->WScreen },
  79.       { WA_Activate, TRUE},
  80.       { WA_IDCMP, IDCMP_VANILLAKEY |
  81.                   IDCMP_MOUSEBUTTONS |
  82.                   IDCMP_GADGETUP |
  83.                   IDCMP_REFRESHWINDOW |
  84.                   IDCMP_CLOSEWINDOW },
  85.       { TAG_DONE, NULL}
  86.     };
  87.     Wnd=OpenWindowTagList(NULL,window_tags);
  88.   }
  89.  
  90.   if(Wnd)
  91.   {
  92.  
  93.       int RT,terminated=FALSE;
  94.       cPrefsBetGadgets prefsgads(Wnd,game);
  95.  
  96.       while(!terminated) {
  97.         Message *msg;
  98.  
  99.         WaitPort(Wnd->UserPort);
  100.         while(msg=GetMsg(Wnd->UserPort)) {
  101.  
  102.           if((RT=prefsgads.IDCMP((const IntuiMessage *)msg))==IDCMP_NOT_DONE)
  103.             switch(((IntuiMessage *)msg)->Class) {
  104.               case IDCMP_CLOSEWINDOW: terminated=TRUE; break;
  105.             }
  106.           if(RT==IDCMP_TERMINATED) terminated=TRUE;
  107.           if(RT!=IDCMP_REPLYED) ReplyMsg(msg);
  108.         }
  109.       }
  110.  
  111.     CloseWindow(Wnd);
  112.   }
  113. }
  114.  
  115.  
  116. int cPrefsBetGadgets::GadgetOK()
  117. {
  118.   int c=GetGadgetString(changes)-'0';
  119.   game->SetChanges(c);
  120.   c=GetGadgetString(jokers)-'0';
  121.   game->SetJokers(c);
  122.   return IDCMP_TERMINATED;
  123. }
  124.  
  125.  
  126. int cPrefsBetGadgets::IDCMP(const IntuiMessage *msg)
  127. {
  128.   switch(msg->Class) {
  129.     case IDCMP_REFRESHWINDOW: GT_BeginRefresh(wnd);
  130.                               GT_EndRefresh(wnd, TRUE);
  131.                               return IDCMP_DONE;
  132.  
  133.     case IDCMP_VANILLAKEY:
  134.          switch(msg->Code) {
  135.            case 10:
  136.            case 13:  return GadgetOK();
  137.            case 27:  return IDCMP_TERMINATED;
  138.            case 'c':
  139.            case 'C':
  140.            case 9:   ActivateGadget(changes,wnd,NULL);
  141.                      return IDCMP_DONE;
  142.            case 'j':
  143.            case 'J': ActivateGadget(jokers,wnd,NULL);
  144.                      return IDCMP_DONE;
  145.          }
  146.          break;
  147.     case IDCMP_GADGETUP:
  148.          Gadget *gad = (struct Gadget *)msg->IAddress;
  149.          switch(gad->GadgetID) {
  150.            case STRING_CHANGES:
  151.                 {
  152.                   int c=GetGadgetString(gad)-'0';
  153.                   if(c<1) c=1;
  154.                   if(c>MAX_CHANGES) c=MAX_CHANGES;
  155.                   SetGadgetString(gad,c+'0');
  156.                   break;
  157.                 }
  158.            case STRING_JOKERS:
  159.                 {
  160.                   int c=GetGadgetString(gad)-'0';
  161.                   if(c<0) c=0;
  162.                   if(c>MAX_JOKERS) c=MAX_JOKERS;
  163.                   SetGadgetString(gad,c+'0');
  164.                   break;
  165.                 }
  166.            case GADGET_OK: return GadgetOK();
  167.            case GADGET_CANCEL: return IDCMP_TERMINATED;
  168.          }
  169.          return IDCMP_DONE;
  170.   }
  171.   return IDCMP_NOT_DONE;
  172. }
  173.  
  174. #endif
  175.